<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of mmw_command_ReadTagsByTagCommand
 *
 * @author Manu
 */
require_once("mmw_command_Command.php");
require_once(dirname(__FILE__) . "/../core/mmw_core_AppException.php");
require_once(dirname(__FILE__) . "/../controller/mmw_controller_Request.php");
require_once(dirname(__FILE__) . "/../mapper/mmw_mapper_TagMapper.php");

class mmw_command_ReadTagsByTagCommand extends mmw_command_Command {
    public function doExecute(mmw_controller_Request $request) {
        if ($request->getProperty("key")==null) {
            throw new mmw_core_AppException("Missing parameter 'key'");
        }
        
        $keyword=$request->getProperty("key");
        
        //1) we fetch the list of tags which value matches the value passed in parameter 'tag'
        $tagMapper=new mmw_mapper_TagMapper();
        $arTags=$tagMapper->findByTagLike($keyword);
        
        $request->setResults($arTags);
        $request->addFeedback("Fetched ".count($arTags)." tags which value matches '$keyword'");
        $request->setSuccess(true);
    }
}

?>
